/**
 * author: huangyu
 * Tips消息提示组件
 */
import React, { Component } from 'react';
export default class TipsChild extends Component {
    constructor(props) {
        super(props);
        this.state = {
            showAni: false
        };
    }
    componentDidMount() {
        let { show, cancleHandle, params } = this.props;
        this.setState({
            showAni: show
        });
        if (params.type !== 'loading') {
            setTimeout(() => {
                this.setState(
                    {
                        showAni: false
                    },
                    () => {
                        setTimeout(() => {
                            let callBack =
                                typeof params.callBack === 'function'
                                    ? params.callBack
                                    : () => {};
                            callBack();
                            cancleHandle();
                        }, 200);
                    }
                );
            }, 2000);
        } else {
            if (!params.isShow) {
                setTimeout(() => {
                    this.setState(
                        {
                            showAni: false
                        },
                        () => {
                            setTimeout(() => {
                                let callBack =
                                    typeof params.callBack === 'function'
                                        ? params.callBack
                                        : () => {};
                                callBack();
                                cancleHandle();
                            }, 200);
                        }
                    );
                }, 2000);
            }
        }
    }

    componentWillUnmount() {
        // 重写组件的setState方法，直接返回空
        this.setState = (state, callback) => {
            return;
        };
    }
    render() {
        let { params } = this.props;
        let { showAni } = this.state;
        let str = "loading";
        return <div>{str}</div>;
    }
}
